<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue</title>
</head>
<body>
<div id="app">
    <a href="#" @click.prevent="flag=true">reg</a>
    <a href="#" @click.prevent="flag=false">login</a>
    <!--通过v-if else切换-->
    <reg v-if="flag"></reg>
    <login v-else></login>
</div>

<script src="https://unpkg.com/vue/dist/vue.js"></script>

<script>
    Vue.component('reg', {
        template: "<h2>register</h2>"
    });
    Vue.component('login', {
        template: "<h2>login</h2>"
    });
    var vm = new Vue({
        el: '#app',
        data: {
            flag: true
        },
        methods: {
        }
    });
</script>
</body>
</html>
